package Car;

/**
 * @author qqq
 * @version 1.0
 * @date $(DATE)$(TIME)
 * @description
 */
class Car extends Auto {
    // 新增成员变量
    private boolean hasAirConditioner; // 是否有空调
    private boolean hasCDPlayer;       // 是否有 CD 播放器

    // 默认构造方法
    public Car() {
        super(); // 调用父类的默认构造方法
        this.hasAirConditioner = true; // 默认有空调
        this.hasCDPlayer = true;       // 默认有 CD 播放器
    }

    // 带参数的构造方法
    public Car(int tireCount, String color, double weight, boolean hasAirConditioner, boolean hasCDPlayer) {
        super(tireCount, color, weight); // 调用父类的带参数构造方法
        this.hasAirConditioner = hasAirConditioner;
        this.hasCDPlayer = hasCDPlayer;
    }

    // 覆盖加速方法
    @Override
    public void accelerate(double increment) {
        if (increment > 0) {
            speed += increment * 1.2; // 小汽车加速更快
            System.out.println("Car is accelerating faster... Current speed: " + speed + " km/h");
        } else {
            System.out.println("Invalid acceleration value.");
        }
    }

    // 覆盖减速方法
    @Override
    public void decelerate(double decrement) {
        if (decrement > 0 && speed >= decrement) {
            speed -= decrement * 0.8; // 小汽车减速更慢
            System.out.println("Car is decelerating slower... Current speed: " + speed + " km/h");
        } else {
            System.out.println("Invalid deceleration value or speed is too low.");
        }
    }

    // 显示小汽车信息
    @Override
    public void displayInfo() {
        super.displayInfo(); // 调用父类的显示方法
        System.out.println("Car Info: Has Air Conditioner=" + hasAirConditioner + ", Has CD Player=" + hasCDPlayer);
    }
}